package symboltable;

import syntaxtree.Type;

import syntaxtree.Identifier;

public class MethodTable {
    //metodos possuem parametros e variaveis locais    
    private ParamsTable paramsTable;
    private LocalsTable localsTable;

    public MethodTable() {
        paramsTable = new ParamsTable();
        localsTable = new LocalsTable();
    }

    public void addParams(Identifier identifier, Type type) {
        if (!paramsTable.getHashmapParamsTable().containsKey(Symbol.symbol(identifier.s))) {
            paramsTable.getHashmapParamsTable().put(Symbol.symbol(identifier.s), type);
        }
    }

    public void addLocals(Identifier identifier, Type type) {
        if (!localsTable.getHashmapLocalsTable().containsKey(Symbol.symbol(identifier.s))) {
            localsTable.getHashmapLocalsTable().put(Symbol.symbol(identifier.s), type);
        }
    }

    public ParamsTable getParamsTable() {
        return paramsTable;
    }

    public void setParamsTable(ParamsTable paramsTable) {
        this.paramsTable = paramsTable;
    }

    public LocalsTable getLocalsTable() {
        return localsTable;
    }

    public void setLocalsTable(LocalsTable localsTable) {
        this.localsTable = localsTable;
    }
}
